home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /***************************************************************************
- * This is a sample code that maps Eisa slot 1 address to the user's
- * address space. Knowing the Eisa slot 1 base address, the program
- * maps an ISA card installed there and accesses a register on the
- * card.
- ****************************************************************************/
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <sys/types.h>
- #include <sys/mman.h>
-
- #define GPIS 6 /* offset of GPIS register in our ISA card */
-
- /*
- * maps RAP-10 card to user's address space
- */
- main()
- {
-
- caddr_t eisaAddr; /* Eisa slot 1 base address */
- caddr_t cardAddr; /* our ISA card IO address */
- off_t slotOff; /* slot 1 Offset (0x1000) */
- off_t cardOff; /* ISA card offset (0x330 dip-switched) */
- size_t slotLen; /* slot 1 length (0x1000) */
- int fd;
-
- slotOff = 0x1000;
- cardOff = 0x330;
- slotLen = 0x1000;
-
- /* open Eisa IO address space */
- fd = open ("/dev/eisa/eisa0io", O_RDWR );
- if ( fd <= 0 ) {
- printf ("Error accesing Eisa IO, errno = %d\n", errno );
- exit(0);
- }
-
- /* map Eisa slot 1 address */
- eisaAddr = (caddr_t) mmap ((void *)0, slotLen, (PROT_READ|PROT_WRITE),
- MAP_PRIVATE, fd, slotOff);
- if ( eisaAddr < (caddr_t)0 ) {
- printf ("Error mapping, errno = %d\n", errno );
- printf ("eisaAddr = %d [%x]\n", eisaAddr, eisaAddr);
- close(fd);
- exit(0);
- }
-
- printf ("Eisa Adress is: %x\n", eisaAddr );
-
- /* calculate our ISA card address and print GPIS register */
- cardAddr = eisaAddr + cardOff;
- printf ("card Address is: %x\n", cardAddr);
- printf ("GPIS register is: %x\n", cardAddr[GPIS] );
- close(fd);
- }
-
-